TimerInt
 
 
 Bean TimerInt
 
Periodic interrupt

Typical usage of the bean in user's code.

Typical Usage:

Required bean name is "TI1".
There are the following two typical usage modes:

(1)
The easiest usage of the bean is a simple periodic event generator. The event handler "TI1_OnInterrupt" is generated with a selected period. Event handler executes as shown in the following example (no method is used):

 EVENTS.C

int i = 0;
void TI1_OnInterrupt(void)
{
  ++i;
}
Note: In this case it is recommended to turn off all the methods of the bean.

(2)
Advanced methods of the bean allows to change period of the event in runtime. It is possible to select a period from the predefined list using SetPeriodMode method or to set a value from the interval using SetPeriod and SetFreq methods (please refer to Bean Timing Dialog). It is also possible to change the event period in the event handler.
In the following example the event period is switched after each 255-th invocation of the event handler. The mode is changed sequentially from three predefined values.

 EVENTS.C

int rpt_cntr = 255, mode = 0;

void TI1_OnInterrupt(void)
{

  if( --rpt_cntr==0 ) {  // If the event was generated 255times
    if( ++mode==3 ) mode = 0; // Select next mode of the period
    TI1_SetPeriodMode( mode );// Set new period mode
    rpt_cntr = 255; // Set repeat counter
  }
}

For more about typical usage of the bean code please refer to the page Bean Code Typical Usage.


Processor ExpertTM and Embedded BeansTM are registered trademarks of UNIS, Ltd.
©1997-2005, UNIS, Ltd.